package com.aeric.qrpro;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import com.aeric.CWApplication.AppInfo;


/**
 * Created by lenovo on 2015/12/23.
 */
public class StartUpActivity extends Activity {
    AppInfo appInfo;
    /**
     * onCreate
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();
        //隐藏标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //隐藏状态栏
        //定义全屏参数
        int flag= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        //设置当前窗体为全屏显示
        window.setFlags(flag, flag);
        setContentView(R.layout.activity_startup);
        appInfo = new AppInfo(getApplicationContext());
        //延时线程
        new Thread() {
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch(InterruptedException e) {
                }
                //判断是否为首次登陆
                Intent intent = new Intent();
                if (appInfo.isNewVersion()) {
                    intent.setClass(StartUpActivity.this,IntroActivity.class);
                    intent.putExtra("goto", MainActivity.class.getName());
                    appInfo.markCurrentVersion(); //标记当前版本
                    startActivity(intent);
                } else {
                    intent.setClass(StartUpActivity.this,MainActivity.class);
                    startActivity(intent);
                }
                finish();
            }
        }.start();
    }

}
